package com.fjnldx.mes.mapper.environment;

import com.fjnldx.mes.domain.domainReq.TempHumidityPageReq;
import com.fjnldx.mes.domain.domainReq.TempHumidityReq;
import com.fjnldx.mes.domain.domainRes.TempAndHumidityInfoRes;
import com.fjnldx.mes.domain.energy.vo.TempHumidityPageVO;
import com.fjnldx.mes.domain.pojo.WenshiduTable;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface EnvironmentMapper {

    @Select("select date_format(time, '%H:00') timeStr, max(ifnull(xswd1, 0)) xswd1, max(ifnull(xssd1, 0)) xssd1, max(ifnull(xswd2, 0)) xswd2, max(ifnull(xssd2, 0)) xssd2, max(ifnull(xswd3, 0)) xswd3, max(ifnull(xssd3, 0))xssd3, max(ifnull(ltwd8, 0)) ltwd8, max(ifnull(ltsd8, 0)) ltsd8, max(ifnull(ltwd9, 0)) ltwd9, max(ifnull(ltsd9, 0)) ltsd9, max(ifnull(xswd4, 0)) xswd4, max(ifnull(xssd4, 0)) xssd4, max(ifnull(xswd5, 0)) xswd5, max(ifnull(xssd5, 0)) xssd5, max(ifnull(xswd6, 0)) xswd6, max(ifnull(xssd6, 0)) xssd6, max(ifnull(bnwd7, 0)) bnwd7, max(ifnull(bnsd7, 0)) bnsd7 from wenshidu_table where date_format(time, '%Y%m%d') = #{time} group by date_format(time, '%H:00')")
    List<WenshiduTable> getTempHumidityByIntegralPoint(@Param("time") String time);

    @Select("select xswd1, xssd1, xswd2, xssd2, xswd3, xssd3, ltwd8, ltsd8, ltwd9, ltsd9, xswd4, xssd4, xswd5, xssd5, xswd6, xssd6, bnwd7, bnsd7 from wenshidu_table order by time desc LIMIT 1")
    WenshiduTable getTempHumidityByCurrentTime();

    List<TempHumidityPageVO> getHistoryTempHumidityByPage(TempHumidityPageReq tempHumidityPageReq);

    List<TempAndHumidityInfoRes> getHistoryTempHumidity(TempHumidityReq tempHumidityReq);

    List<Map<String, String>> getTempHumidityTable(@Param("dictCodes") List<Integer> dictCodes);
}
